Skip to content

Harden tool policy runtime and malformed decision handling - #251

Open
gut-puncture wants to merge 3 commits into
google-deepmind:mainfrom
gut-puncture:codex/policy-runtime-v2-core
Open

Harden tool policy runtime and malformed decision handling#251
gut-puncture wants to merge 3 commits into
google-deepmind:mainfrom
gut-puncture:codex/policy-runtime-v2-core

Conversation

@gut-puncture

Copy link
Copy Markdown
Contributor

Summary

This PR delivers the v2 core policy-runtime hardening for InteractiveDocumentWithTools.

Changes:

  • fixes malformed-policy handling contract:
    • observe mode fails open (tool executes, logs tool_policy_error_observed)
    • enforce mode fails closed (tool blocked, logs tool_policy_error_enforced)
  • refactors policy runtime into explicit helpers for readability and maintenance:
    • _evaluate_policy_decision
    • _coerce_policy_decision
    • _apply_policy_decision
    • _policy_error_outcome
  • adds robust coercion for malformed PolicyDecision fields (including invalid tags shape)
  • keeps default behavior unchanged when no policy is configured

Why

The previous implementation could incorrectly block tool execution in observe mode for malformed policy output. This PR makes failure semantics explicit and deterministic.

Test Coverage

  • malformed policy return object
  • malformed action
  • malformed tags payload
  • policy exceptions
  • observe/enforce behavior checks
  • existing tool-runtime behavior regression checks

Validation

Executed locally:

  • . .venv/bin/activate && python -m pytest -q concordia/document/interactive_document_tools_test.py
  • . .venv/bin/activate && python -m pytest -q concordia/document/tool_policy_test.py
  • . .venv/bin/activate && python -m pytest -q concordia/document
  • . .venv/bin/activate && python -m pylint --errors-only on touched files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant